<template>
    <div class="case-detail">
        <div class="header">
            <span class="title1 txt-theme">案例详情</span>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/case/caseLists' }"
                    >案例列表</el-breadcrumb-item
                >
                <el-breadcrumb-item>案例详情</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="desc bg-white">
            <p class="title2">{{ detailData.CASE_NAME }}</p>
            <div class="detail flex-row">
                <el-image
                    :src="$store.getters.imgUrl + detailData.CASE_LOGO"
                    fit="cover"
                >
                    <div slot="error" class="image-slot">
                        <i class="el-icon-picture-outline"></i>
                    </div>
                </el-image>
                <p class="content">{{ detailData.CASE_DESC }}</p>
            </div>
        </div>
        <div
            class="case-img"
            v-if="detailData.IMG_URL && detailData.IMG_URL.length"
        >
            <div class="headline">
                <span>案例图片</span>
            </div>
            <div class="card">
                <el-carousel
                    indicator-position="none"
                    height="100%"
                    :autoplay="false"
                >
                    <el-carousel-item
                        v-for="(item, index) in detailData.IMG_URL"
                        :key="index"
                    >
                        <el-image
                            :src="$store.getters.imgUrl + item.url"
                            fit="contain"
                        >
                        </el-image>
                        <div class="img-desc">
                            {{ item.tip }}（{{ index + 1 }}/{{
                                detailData.IMG_URL.length
                            }}）
                        </div>
                    </el-carousel-item>
                </el-carousel>
            </div>
        </div>
        <div
            class="case-video"
            v-if="detailData.video && detailData.video.length"
        >
            <div class="headline">
                <span>案例视频</span>
            </div>
            <div class="card">
                <video
                    :src="detailData.video"
                    height="100%"
                    width="100%"
                    controls
                >
                    <p>你的浏览器不支持video标签</p>
                </video>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                id: '',
                detailData: {},
            }
        },
        methods: {
            getCaseDetail() {
                this.$http
                    .getCaseDetail({ uids: this.id })
                    .then((res) => {
                        if (res.success) {
                            this.detailData = res.data
                            this.detailData.IMG_URL = JSON.parse(
                                this.detailData.IMG_URL
                            )
                        }
                    })
                    .catch((err) => {
                        this.$msgAlert(err)
                    })
            },
        },
        mounted() {
            this.id = this.$route.params.id
            this.getCaseDetail()
        },
        activated() {
            this.id = this.$route.params.id
            this.getCaseDetail()
        },
    }
</script>

<style lang="scss">
    .case-detail {
        margin: 30px 0 60px;
        .header {
            display: flex;
            justify-content: space-between;
            padding-bottom: 30px;
            border-bottom: 2px solid #5095f7;
            .title1 {
                font-size: 22px;
                font-weight: bold;
                line-height: 24px;
            }
        }
        .desc {
            padding: 30px;
            .title2 {
                font-size: 20px;
                font-weight: bold;
                color: #333333;
                line-height: 24px;
                margin-bottom: 20px;
            }
            .el-image {
                width: 160px;
                height: 160px;
                vertical-align: middle;
                .image-slot {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 100%;
                    height: 100%;
                    background: #f5f7fa;
                    color: #909399;
                    font-size: 30px;
                }
            }
            .content {
                flex: 1;
                font-size: 16px;
                font-weight: 400;
                color: #666666;
                line-height: 27px;
                margin-left: 20px;
                text-align: justify;
            }
        }
        .headline {
            padding: 10px 0;
            &::before {
                content: '';
                display: inline-block;
                width: 4px;
                height: 16px;
                background: linear-gradient(0deg, #53d0ff 0%, #5095f7 100%);
                margin-right: 30px;
                vertical-align: middle;
            }
            span {
                font-size: 16px;
                font-weight: bold;
                color: #333333;
                line-height: 24px;
            }
        }
        .card {
            padding: 30px;
            background: #fff;
            height: 690px;
        }
        .case-img {
            .el-carousel {
                height: 100%;
                background: #fff;
                .el-image {
                    width: 100%;
                    height: 100%;
                    background: #000;
                }
                .el-carousel__arrow {
                    width: 80px;
                    height: 120px;
                    border-radius: 0;
                    background: rgba(0, 0, 0, 0.3);
                    font-size: 75px;
                }
                .img-desc {
                    position: absolute;
                    left: 0;
                    right: 0;
                    top: 0px;
                    height: 50px;
                    background: rgba(0, 0, 0, 0.3);
                    color: #fff;
                    text-align: center;
                    line-height: 50px;
                    font-weight: bold;
                    font-size: 16px;
                }
            }
        }
    }
</style>
